package com.zszq.ms.bigmodeltest.controller;

import com.zszq.ms.bigmodeltest.domain.response.Result;
import com.zszq.ms.bigmodeltest.entity.AiBigmodelConfig;
import com.zszq.ms.bigmodeltest.entity.AiTask;
import com.zszq.ms.bigmodeltest.entity.AiTaskResult;
import com.zszq.ms.bigmodeltest.mapper.AiBigmodelConfigMapper;
import com.zszq.ms.bigmodeltest.mapper.AiTaskMapper;
import com.zszq.ms.bigmodeltest.task.TaskUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 子任务前端控制器
 *
 * @author ms
 * @since 2025-03-31
 */
@RestController
@RequestMapping("/aiTaskResult")
public class AiTaskResultController {

    @Autowired
    private TaskUtils taskUtils;

    @Autowired
    private AiTaskMapper aiTaskMapper;

    @Autowired
    private AiBigmodelConfigMapper aiBigmodelConfigMapper;

    @PostMapping("/subTaskHandle")
    public Result subTaskHandle(@RequestBody AiTaskResult aiTaskResult) {
        AiTask aiTask = aiTaskMapper.selectById(aiTaskResult.getTaskId());
        AiBigmodelConfig aiBigmodelConfig = aiBigmodelConfigMapper.selectById(aiTaskResult.getBigModelConfigId());
        return taskUtils.subTaskHandle(aiTaskResult, aiTask, aiBigmodelConfig.getCode());
    }

}
